#include <Windows.h>
#include <fcntl.h>
#include <stdio.h>
#include <io.h>
#include <Psapi.h>
#include <detours.h>
#include <fstream>
#pragma comment (lib, "psapi.lib")

#include "Utilits.h"
Utilits ut;
DWORD WINAPI my_thread(LPVOID);

DWORD APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
	switch(ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
		CreateThread(NULL, NULL, my_thread, NULL, NULL, NULL);
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return true;
}
DWORD WINAPI my_thread(LPVOID)
{
	ut.CreateConsole();
	ofstream o("offsets.txt");
	FILE* f = fopen("offsets.txt", "w");
	MODULEINFO moduleInf = ut.GetModuleData("mu.exe");
	printf("Base = 0x%X, Size = %X\n", moduleInf.lpBaseOfDll, moduleInf.SizeOfImage);
	vector<DWORD> addr = ut.FindPattern((DWORD)moduleInf.lpBaseOfDll, moduleInf.SizeOfImage, 
		(PBYTE)"\xFF\x15\x00\x00\x00\x00\xFF\xD3\x8B\x74\x24\x28\x2B\xC6\x83\xF8\x28\x7D\x09", "xx????xxxxxxxxxxxxx");
	for(int i = 0 ; i < addr.size(); i++)
	{
		fprintf(f,"Look 0x %X" , addr[i]);
		printf("Look 0x %X" , addr[i]);
	}
	system("pause >> void");
	return 0;
}